/*     */ package com.zimbra.cs.account;
/*     */ 
/*     */ import com.zimbra.common.localconfig.KnownKey;
/*     */ import com.zimbra.common.localconfig.LC;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.LogFactory;
/*     */ import com.zimbra.cs.account.soap.SoapProvisioning;
/*     */ import com.zimbra.cs.util.Zimbra;
/*     */ import com.zimbra.soap.admin.message.RefreshRegisteredAuthTokensRequest;
/*     */ import java.util.Arrays;
/*     */ import java.util.List;
/*     */ import java.util.Timer;
/*     */ import java.util.TimerTask;
/*     */ import java.util.concurrent.ConcurrentLinkedQueue;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public final class AuthTokenRegistry
/*     */ {
/*  41 */   private static final Log mLOG = LogFactory.getLog(AuthTokenRegistry.class);
/*     */   
/*  43 */   private static final ConcurrentLinkedQueue<ZimbraAuthToken> deregisteredOutAuthTokens = new ConcurrentLinkedQueue();
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public static final void addTokenToQueue(ZimbraAuthToken token)
/*     */   {
/*  50 */     while ((deregisteredOutAuthTokens.size() > LC.zimbra_deregistered_authtoken_queue_size.intValue()) && (!deregisteredOutAuthTokens.isEmpty()))
/*     */     {
/*  52 */       deregisteredOutAuthTokens.remove();
/*     */     }
/*  54 */     deregisteredOutAuthTokens.add(token);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public static void startup(long interval)
/*     */   {
/*  62 */     Zimbra.sTimer.schedule(new SendTokensTimerTask(), interval, interval);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   private static final class SendTokensTimerTask
/*     */     extends TimerTask
/*     */   {
/*     */     public void run()
/*     */     {
/*  72 */       AuthTokenRegistry.mLOG.debug("Broadcasting dergistered authtokens");
/*     */       
/*  74 */       Object[] copy = AuthTokenRegistry.deregisteredOutAuthTokens.toArray();
/*     */       
/*     */ 
/*  77 */       if (copy.length > 0) {
/*  78 */         AuthTokenRegistry.mLOG.debug("Found some dergistered authtokens to broadcast");
/*     */         
/*     */ 
/*     */ 
/*     */ 
/*  83 */         AuthTokenRegistry.deregisteredOutAuthTokens.removeAll(Arrays.asList(copy));
/*     */         
/*     */         try
/*     */         {
/*  87 */           List<Server> mailServers = Provisioning.getInstance().getAllMailClientServers();
/*  88 */           soapProv = SoapProvisioning.getAdminInstance();
/*  89 */           soapProv.soapZimbraAdminAuthenticate();
/*  90 */           req = new RefreshRegisteredAuthTokensRequest();
/*  91 */           for (Object ztoken : copy) {
/*  92 */             if (!((ZimbraAuthToken)ztoken).isExpired()) {
/*  93 */               req.addToken(((ZimbraAuthToken)ztoken).getEncoded());
/*     */             }
/*     */           }
/*  96 */           for (Server server : mailServers)
/*  97 */             if (!server.isLocalServer())
/*     */             {
/*     */ 
/* 100 */               soapProv.invokeJaxb(req, server.getName()); }
/*     */         } catch (ServiceException|AuthTokenException e) { SoapProvisioning soapProv;
/*     */           RefreshRegisteredAuthTokensRequest req;
/* 103 */           AuthTokenRegistry.mLOG.error("Failed to broadcast deregistered authtokens", e);
/*     */         }
/*     */       }
/*     */     }
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/AuthTokenRegistry.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */